<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../../style.css" type="text/css" media="screen">
<link rel="stylesheet" href="../../../../print.css" type="text/css" media="print">
<meta content="NumberUtil,com.yahoo.astra.utils.NumberUtil,fuzzyEquals,roundDownToNearest,roundToNearest,roundToPrecision,roundUpToNearest" name="keywords">
<title>com.yahoo.astra.utils.NumberUtil</title>
</head>
<body>
<script type="text/javascript" language="javascript" src="../../../../asdoc.js"></script><script type="text/javascript" language="javascript" src="../../../../cookies.js"></script><script type="text/javascript" language="javascript">
<!--
				asdocTitle = 'NumberUtil - YUI AS Component Documentation';
				var baseRef = '../../../../';
				window.onload = configPage;
			--></script>
<table style="display:none" id="titleTable" cellspacing="0" cellpadding="0" class="titleTable">
<tr>
<td align="left" class="titleTableTitle">YUI AS Component Documentation</td><td align="right" class="titleTableTopNav"><a onclick="loadClassListFrame('../../../../all-classes.html')" href="../../../../package-summary.html">All&nbsp;Packages</a>&nbsp;|&nbsp;<a onclick="loadClassListFrame('../../../../all-classes.html')" href="../../../../class-summary.html">All&nbsp;Classes</a>&nbsp;|&nbsp;<a onclick="loadClassListFrame('../../../../index-list.html')" href="../../../../all-index-A.html">Index</a>&nbsp;|&nbsp;<a href="../../../../index.html?com/yahoo/astra/utils/NumberUtil.html&amp;com/yahoo/astra/utils/class-list.html" id="framesLink1">Frames</a><a onclick="parent.location=document.location" href="" style="display:none" id="noFramesLink1">No&nbsp;Frames</a></td><td rowspan="3" align="right" class="titleTableLogo"><img alt="Adobe Logo" title="Adobe Logo" class="logoImage" src="../../../../images/logo.jpg"></td>
</tr>
<tr class="titleTableRow2">
<td align="left" id="subTitle" class="titleTableSubTitle">Class&nbsp;NumberUtil</td><td align="right" id="subNav" class="titleTableSubNav"><a href="#methodSummary">Methods</a></td>
</tr>
<tr class="titleTableRow3">
<td colspan="2">&nbsp;</td>
</tr>
</table>
<script type="text/javascript" language="javascript">
<!--
if (!isEclipse() || window.name != ECLIPSE_FRAME_NAME) {titleBar_setSubTitle("Class NumberUtil"); titleBar_setSubNav(false,false,false,false,false,false,true,false,false,false,false,false,false,false);}
--></script>
<div class="MainContent">
<table cellspacing="0" cellpadding="0" class="classHeaderTable">
<tr>
<td class="classHeaderTableLabel">Package</td><td><a onclick="javascript:loadClassListFrame('class-list.html')" href="package-detail.html">com.yahoo.astra.utils</a></td>
</tr>
<tr>
<td class="classHeaderTableLabel">Class</td><td class="classSignature">public class NumberUtil</td>
</tr>
</table>
<p></p>
  A collection of utility functions for the manipulation of numeric values.
  
  <p></p>
<br>
<hr>
</div>
<a name="methodSummary"></a>
<div class="summarySection">
<div class="summaryTableTitle">Public Methods</div>
<table id="summaryTableMethod" class="summaryTable " cellpadding="3" cellspacing="0">
<tr>
<th>&nbsp;</th><th colspan="2">Method</th><th class="summaryTableOwnerCol">Defined&nbsp;by</th>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#fuzzyEquals()">fuzzyEquals</a>(number1:Number, number2:Number, precision:int = 5):Boolean</div>
<div class="summaryTableDescription">[static]
   Tests equality for numbers that may have been generated by faulty floating point math.</div>
</td><td class="summaryTableOwnerCol">NumberUtil</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#roundDownToNearest()">roundDownToNearest</a>(number:Number, nearest:Number = 1):Number</div>
<div class="summaryTableDescription">[static]
   Rounds a Number <em>down</em> to the nearest multiple of an input.</div>
</td><td class="summaryTableOwnerCol">NumberUtil</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#roundToNearest()">roundToNearest</a>(number:Number, nearest:Number = 1):Number</div>
<div class="summaryTableDescription">[static]
   Rounds a Number to the nearest multiple of an input.</div>
</td><td class="summaryTableOwnerCol">NumberUtil</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#roundToPrecision()">roundToPrecision</a>(number:Number, precision:int = 0):Number</div>
<div class="summaryTableDescription">[static]
   Rounds a number to a certain level of precision.</div>
</td><td class="summaryTableOwnerCol">NumberUtil</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#roundUpToNearest()">roundUpToNearest</a>(number:Number, nearest:Number = 1):Number</div>
<div class="summaryTableDescription">[static]
   Rounds a Number <em>up</em> to the nearest multiple of an input.</div>
</td><td class="summaryTableOwnerCol">NumberUtil</td>
</tr>
</table>
</div>
<script type="text/javascript" language="javascript">
<!--
showHideInherited();
--></script>
<div class="MainContent">
<a name="methodDetail"></a>
<div class="detailSectionHeader">Method detail</div>
<a name="fuzzyEquals()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">fuzzyEquals</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td>
</tr>
</table>
<div class="detailBody">
<code>public static function fuzzyEquals(number1:Number, number2:Number, precision:int = 5):Boolean</code><p>
   Tests equality for numbers that may have been generated by faulty floating point math.
   This is not an issue exclusive to the Flash Player, but all modern computing in general.
   The value is generally offset by an insignificant fraction, and it may be corrected.
   
   </p><p>Alternatively, this function could be used for other purposes than to correct floating
   point errors. Certainly, it could determine if two very large numbers are within a certain
   range of difference. This might be useful for determining "ballpark" estimates or similar
   statistical analysis that may not need complete accuracy.</p>
   
   <span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">number1</span>:Number</code> &mdash; number1  the first number to test
   </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">number2</span>:Number</code> &mdash; number2  the second number to test
   </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">precision</span>:int</code> (default = <code>5</code>)<code></code> &mdash; precision the number of digits in the fractional portion to keep
   </td>
</tr>
</table>
<p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>Boolean</code> &mdash;  true, if the numbers are close enough to be considered equal, false if not.
   </td>
</tr>
</table>
</div>
<a name="roundDownToNearest()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">roundDownToNearest</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public static function roundDownToNearest(number:Number, nearest:Number = 1):Number</code><p>
   Rounds a Number <em>down</em> to the nearest multiple of an input. For example, by rounding
   16 down to the nearest 10, you will receive 10. Similar to the built-in function Math.floor().
   
   </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">number</span>:Number</code> &mdash;  the number to round down
   </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">nearest</span>:Number</code> (default = <code>1</code>)<code></code> &mdash;    the number whose mutiple must be found
   </td>
</tr>
</table>
<p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>Number</code> &mdash; the rounded number
   
   </td>
</tr>
</table>
<p>
<span class="label">See also</span>
</p>
<div class="seeAlso">Math.floor</div>
</div>
<a name="roundToNearest()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">roundToNearest</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public static function roundToNearest(number:Number, nearest:Number = 1):Number</code><p>
   Rounds a Number to the nearest multiple of an input. For example, by rounding
   16 to the nearest 10, you will receive 20. Similar to the built-in function Math.round().
   
   </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">number</span>:Number</code> &mdash;  the number to round
   </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">nearest</span>:Number</code> (default = <code>1</code>)<code></code> &mdash;    the number whose mutiple must be found
   </td>
</tr>
</table>
<p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>Number</code> &mdash; the rounded number
   
   </td>
</tr>
</table>
<p>
<span class="label">See also</span>
</p>
<div class="seeAlso">Math.round</div>
</div>
<a name="roundToPrecision()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">roundToPrecision</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public static function roundToPrecision(number:Number, precision:int = 0):Number</code><p>
   Rounds a number to a certain level of precision. Useful for limiting the number of
   decimal places on a fractional number.
   
   </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">number</span>:Number</code> &mdash; number  the input number to round.
   </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">precision</span>:int</code> (default = <code>0</code>)<code></code> &mdash; precision the number of decimal digits to keep
   </td>
</tr>
</table>
<p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>Number</code> &mdash;  the rounded number, or the original input if no rounding is needed
   
   </td>
</tr>
</table>
<p>
<span class="label">See also</span>
</p>
<div class="seeAlso">Math.round</div>
</div>
<a name="roundUpToNearest()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">roundUpToNearest</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public static function roundUpToNearest(number:Number, nearest:Number = 1):Number</code><p>
   Rounds a Number <em>up</em> to the nearest multiple of an input. For example, by rounding
   16 up to the nearest 10, you will receive 20. Similar to the built-in function Math.ceil().
   
   </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">number</span>:Number</code> &mdash;  the number to round up
   </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">nearest</span>:Number</code> (default = <code>1</code>)<code></code> &mdash;    the number whose mutiple must be found
   </td>
</tr>
</table>
<p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>Number</code> &mdash; the rounded number
   
   </td>
</tr>
</table>
<p>
<span class="label">See also</span>
</p>
<div class="seeAlso">Math.ceil</div>
</div>
<br>
<br>
<hr>
<br>
<p></p>
<center class="copyright"> 
</center>
</div>
</body>
</html>
<!-- -->
